<?php
class jobAction extends security_normal {
	
	function action(){
		$miceSession = new session();
		if($miceSession->get('mu__userid')<1){
			$uid=0;
			$name='';
		}else{
			$uid=$miceSession->get('mu__userid');
			$name=$miceSession->get('mu__loginname');
		}

		$jobid=ceil($this->_getParamId(1));
		$article=new model_Article();
		$article->setSubsection('WHERE isvisible=0 AND type=\'article4\' AND article_id='.$jobid);
		$ArticleRS=$article->doSelectOne();
		if(!$ArticleRS){
			MessageBox('提示','back','对不起,您查看的招聘岗位不存在或已经被删除');
			exit;
		}

		if($ArticleRS->getIsremark()!=0){
			MessageBox('提示','back','对不起,您查看的招聘岗位不允许在线提交简历');
			exit;
		}

		global $conn;
		if($_POST){
			if($_POST['checkcode']<>$miceSession->get('checkcode')){
				MessageBox('验证码错误','back'.'index.php/job/'.$jobid);
				exit;
			}

			if($_POST['name']==''){
				MessageBox('请填写姓名','back'.'index.php/job/'.$jobid);
				exit;
			}

			$form=new model_Form();
			$form->setName($_POST['name']);
			$form->setUserId($uid);
			$form->setEmail(MiceFilterHtml($_POST['email']));
			$form->setTitle(MiceFilterHtml($_POST['title']));
			$form->setCreatedat(time());
			$form->setType('job');
			$form->setIp(GetRealIp());
			$form->setContent(MiceFilterQuote($_POST['content']));
			$results=$form->doInsert();

			if($results)
				$exeresult='提交成功';
			else
				$exeresult='提交失败';
			MessageBox($exeresult,MICE_URL,'您的应聘信息已提交,请等待我们和您联系');
			exit;
		}

		$editor='';
		//调用插件
		$plugin=new model_Plugin();
		$plugin->setSubsection('WHERE isopen=1 AND hook=\'editor_fast\' ORDER BY orderid ASC,plugin_id DESC');
		$plugins=$plugin->doSelectOne();
		include_once MICE_DIR.'includes/plugin.php';
		if($plugins){
			if(file_exists(MICE_DIR.'plugins/'.$plugins->getName().'/index.php')){
				include_once MICE_DIR.'plugins/'.$plugins->getName().'/index.php';
				add_filter('editor_fast', $plugins->getName());
				$editor=apply_filters('editor_fast',0);
				remove_filter('editor_fast', $plugins->getName());
			}
		}

		if($editor==''){
			$editor='<textarea id="MCEname" name="MCEname" rows="15" cols="80" style="width: 100%">MCEcontent</textarea>';
		}

		$editor=str_replace('MCEname','content',$editor);
		$editor=str_replace('MCEcontent','',$editor);

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign("name",$name);
		$smarty->assign("title",$ArticleRS->getTitle());
		$smarty->assign('editor',$editor);
		$smarty->assign("checkcode",MICE_URL.'code.php');

		$filename = new getTPLFileName(__CLASS__);
		$tpl=$filename->TPLFileName;
		$smarty->display($tpl);
	}	
}
?>